using Net.Common;
using UnityEngine;

/****************************************************
// 功能：
// | Talk To [ 聊来改善地区金融服务环境，助力企业发展 ]
// | Copyright (c) 2021-2025 聊来 All rights reserved.
// | Licensed ( <a href="http://www.apache.org/licenses/LICENSE-2.0">聊来</a> )
// | @Author: 贯彻己道的云 <18970881148@qq.com>
// | DateTime: 2025/3/4 18:16:59
*****************************************************/

public class MatchController : BaseController<MatchController>
{

    public GroupWindow groupWindow;
    
    public override void InitController()
    {
        base.InitController();
        //Debug.Log("MatchController Init");
    }

    /// <summary>
    /// 组队匹配消息回调
    /// </summary>
    /// <param name="msg"></param>
    public void OnMatch(MsgInfo msg)
    {
        MatchResponse response = JsonUtility.FromJson<MatchResponse>(msg.data);
        if (response.type == Constants.NUM_ZERO)
        {
            ui.PopUp(WindowName.Match, response.waitTime);
        }
    }


    /// <summary>
    /// 返回个人主页
    /// </summary>
    public void BackHome()
    {
        ResetOperation();
        ui.Open(WindowName.Lobby);
    }
    
    /// <summary>
    /// 重置所有操作
    /// </summary>
    public void ResetOperation()
    {
        // 取消匹配 
        SendByTcp(RequestType.MATCH, new MatchRequest()
        {
            type = Constants.NUM_ONE,
            teamType = Constants.TEAM_ONE
        });

        ui.ClosePopUp(WindowName.Match);
        groupWindow.ResetView();
    }
}
